package View.CoolSwing;

import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;

import javax.swing.JFrame;
import javax.swing.JPanel;

public class MyTest extends JPanel{
	private boolean isSelected = false;
    private static final Color COLOR1 = new Color(125, 161, 237, 255);//浅蓝色
    private static final Color COLOR2 = new Color(91, 118, 173, 255);//比上面深一点
    private static final Color COLOR3 = new Color(153, 222, 253);//淡绿色
    private static final Color COLOR4 = new Color(213, 239, 252);
    private static final Color COLOR5 = new Color(241, 248, 253);
    
    
	protected  void paintComponent(Graphics g)  {
		setBackground(Color.white);
		Graphics2D g2d = (Graphics2D)g.create();
        GradientPaint p1 = new GradientPaint(0, 0, new Color(0, 0, 0), getWidth(), getHeight(), new Color(100, 100, 100));
        GradientPaint p2 = new GradientPaint(0, 0, new Color(0, 0, 0, 50), getWidth(), getHeight(), new Color(255, 255, 255, 100));
        GradientPaint GP = new GradientPaint(0, 0, COLOR1, 0, getHeight(), COLOR2, true);
        GradientPaint p3 = new GradientPaint(0, 0, COLOR5, 0, getHeight()/2 - 1, COLOR4, true);
        
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.5f));
//	    RadialGradientPaint rgp = new RadialGradientPaint(new Point2D.Double(W/2.0, H/2.0), 
													//		R,
													//		new float[] {0.0f, 1.0f},
													//		new Color[] {COLOR1, COLOR2} );
        
//        g2d.setPaint(GP);
        g2d.setColor(COLOR3);
        g2d.drawRoundRect(0, 0, getWidth()/2 - 1, getHeight()/2 - 1, 20, 20);
        g2d.setPaint(p3);
        g2d.fillRoundRect(0, 0, getWidth()/2 - 2, getHeight()/2 - 2, 20, 20);
        
        
        g2d.setColor(COLOR2);
        g2d.fillRoundRect(getWidth()/2 + 1, getHeight()/2 + 1, getWidth()/2 - 1, getHeight()/2 - 1, 20, 20);
        g2d.drawRoundRect(getWidth()/2 + 1, 0, getWidth()/2 - 1, getHeight()/2 - 1, 20, 20);
        
        g2d.setPaint(p1);
        g2d.drawRoundRect(0, getHeight()/2 + 1, getWidth()/2 - 1, getHeight()/2 - 1, 20, 20);
        
        g2d.setPaint(p2);
        g2d.drawRoundRect(getWidth()/2 + 1, 0, getWidth()/2 - 1, getHeight()/2 - 1, 20, 20);

	    g2d.dispose();
	}
	
//	public static void main(String[] args) {
//		JFrame jf = new JFrame("MyTest");
////		JSlider js = new JSlider(0,255);
//		jf.setSize(300, 200);
//		jf.setVisible(true);
//		jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//		jf.add(new MyTest());
////		jf.add(js);
//	}
}
